﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace PrinterApplication.util
{
    class Md5Utils
    {
        public static String getMd5(String value)
        {
            try
            {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] byteValue, byteHash;
                byteValue = System.Text.Encoding.UTF8.GetBytes(value);
                byteHash = md5.ComputeHash(byteValue);

                md5.Clear();

                string sTemp = "";
                for (int i = 0; i < byteHash.Length; i++)
                {
                    sTemp += byteHash[i].ToString("X").PadLeft(2, '0');
                }
                return sTemp.ToLower();
            } catch (Exception e)
            {
               
            }
            return "";
        }
    }
}
